<?php
class actGames extends logCAr
{
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
	
	/* reset db */
	public function getDbConnection()
	{
		self::$db=Yii::app()->db1;
		if(self::$db instanceof CDbConnection) return self::$db;
	}
	
    public function tableName()
	{
		return '{{act_games}}';
	}
    /* rules */
    public function rules()
    {
        return array(
            array('game_name', 'safe', 'on'=>'search'),
        );
    }
    public function search()
    {
        $criteria=new CDbCriteria;
        $criteria->order='create_time desc';
        $criteria->compare('del_flag',0);
        if ($this->game_name)$criteria->compare('game_name',$this->game_name);
        return new CActiveDataProvider($this, array(
            'criteria'=>$criteria,
        ));
    }

    public  static function allgame(){
        $arr = [];
        $arrd = actGames::model()->findAll();
        foreach ($arrd as $r) {
            $arr[$r["id"]] = $r["game_name"];
        }
        return $arr;

    }

    public  static function allm(){
        $arr = [];
        $arrd = ActStock::model()->findAll();
        foreach ($arrd as $r) {
            $arr[$r["id"]] = $r["title"];
        }
        return $arr;

    }

}